<?php 
$sql =	"SELECT
			  c.page_id,
			  d.title,
			  d.description,
			  d.meta_key,
			  d.meta_description	
		  FROM
			  pages AS c,
			  page_description AS d,
			  sef_url AS s
		  WHERE
		  
			  c.page_id = d.page_id
			  AND
			  d.lang_id = '".$_SESSION['lang_id']."'
			  
			  AND
				c.page_id = s.query
				AND
				s.lang_id = '".$_SESSION['lang_id']."'
				AND s.tamplate = 'page'
			 
			  AND
				s.sef_url = 'home' 
		  ";
$result = query($sql);
$row = mysql_fetch_object($result);


head(sth($row->title),sth($row->meta_description),sth($row->meta_key));


?>
<div class="loadLoader">
</div>

<section id="slider">

<div class="timelineLoader">
	<img src="<?=HTML_BASE?>images/loader.gif" />
</div>


	
<div class="timeline">
		<?php 
		
		
				$num_rows = mysql_num_rows(query("SELECT c.project_id FROM
													projects AS c,
													project_description AS d
												WHERE
												
													c.project_id = d.project_id
													
													AND
													
													d.lang_id = '".$_SESSION['lang_id']."'
													AND c.published"));
				$limit = 5	;								
				$start = $num_rows - $limit;
		
				$sql = "SELECT
				c.project_id,
				c.history,
				c.cover,
				c.video,
				c.creation_time,
				d.title,
				d.meta_description,
				d.description
				
			FROM
				projects AS c,
				project_description AS d
			WHERE
			
				c.project_id = d.project_id
				
				AND
				
				d.lang_id = '".$_SESSION['lang_id']."'
				AND c.published
				ORDER BY c.creation_time 
				LIMIT ".$start.",".$limit."
				
			  ";
			$result = query($sql);
			
			while ($row = mysql_fetch_object($result)) {
				
				$date_name = date('d.m.Y',strtotime($row->creation_time)).' г.';
				$date_id = date('d/m/Y',strtotime($row->creation_time));
				
				if($row->history > 0)
				{
					$date_name = $row->history.' г.';
					$date_id = '10/13/'.$row->history;
				}
				
				if($row->history < 0)
				{
					$date_name = abs($row->history).' г. пр. н.е.';
					$date_id = '10/14/'.abs($row->history);
				}
		?>
        
        <div class="item" data-id="<?=$date_id?>" data-name="<?=$date_name?>" data-description="<?=$row->title?>">
            <div style="background-image:url(<?=HTML_BASE?>project_images/covers/<?=$row->cover?>)" ></div>
			<h2><?=$row->title?></h2>
            <div class="zoom"></div>
		</div>
		<div  class="item_open" data-id="<?=$date_id?>">
			
            <div class="timeline_open_content">
			<h2><?=$row->title?></h2>
            <?=$row->description?>
			</div>
            
            <div class="timeline_open_images">
            <?php 
			if($row->video){
				?>
				<a class="video" href="#" data-title="<?=$row->video?>">
			  		<img src="<?=HTML_BASE?>images/video-icon.jpg" height="60" width="60"/>
                </a>	
                <?php
			}
			
			
			$sql_gal = "SELECT g.file, d.description FROM project_gallery AS g, project_gallery_description AS d
						WHERE project_id = '".$row->project_id."' AND g.id = d.image_id AND d.lang_id = '".$_SESSION['lang_id']."'";
			
			$result_gal = query($sql_gal);
			
			if($result_gal){
				?>
				<a href="<?=HTML_BASE?>project_images/big/<?=$row->cover?>">
			  		<img src="<?=HTML_BASE?>project_images/covers/<?=$row->cover?>" height="60" width="60"/>
                </a>	
                <?php
			}
			
			while ($row_gal = mysql_fetch_object($result_gal)) {
					
			?>
            	<a href="<?=HTML_BASE?>project_images/gallery/<?=$row_gal->file?>">
			  		<img src="<?=HTML_BASE?>project_images/gallery/th_<?=$row_gal->file?>" height="60" width="60"/>
                </a>
            <?php
			}
			?>
            </div>

		</div>
        
        <?php }?>

</div>

</section>

<?php
foot('home');
?>